﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Models
{
    [Serializable]
    public class CategoryInfo
    {
        public CategoryInfo() { }

        public CategoryInfo(string categoryID, string categoryName, string linkUrl, string parentID)
        {
            this.CategoryID = categoryID;
            this.CategoryName = categoryName;
            this.LinkUrl = linkUrl;
            this.ParentID = parentID;
        }
        public CategoryInfo(DataTable  reader)
        {
            if (ModelHelper.HasColumn(reader, "id"))
            { 
            this.CategoryID=(string)reader.Rows[0]["id"].ToString();
            }

            if (ModelHelper.HasColumn(reader, "categoryName"))
            {
                this.CategoryName = (string)reader.Rows[0]["categoryName"];
            }

            if (ModelHelper.HasColumn(reader, "parentID"))
            {
                this.ParentID = (string)reader.Rows[0]["parentID"];
            }
            if (ModelHelper.HasColumn(reader, "linkUrl"))
            {
                this.LinkUrl = (string)reader.Rows[0]["linkUrl"];
            }

        }

        /// <summary>
        /// 类别ID
        /// </summary>
        public string CategoryID { get; set; }
        /// <summary>
        /// 类别名称
        /// </summary>
        public string CategoryName { get; set; }
        /// <summary>
        /// 类别链接URl
        /// </summary>
        public string LinkUrl { get; set; }
        /// <summary>
        /// 父级ID
        /// </summary>
        public string ParentID { get; set; }

    }
}
